$(function () {

    layuiFunciton.ajaxRequest({
        url:  layuiFunciton.URL + '/sign/getCurrentUserInfo',
        method: 'get',
        success: function(data){
            $("#id").val(data.id);
            $("#account").val(data.account); //用户名
        }
    });

    //添加验证规则
    layuiFunciton.formVerify({
        oldPwd : function(value, item){
            var tf = false;
            layuiFunciton.ajaxRequest({
                url:  layuiFunciton.URL + '/sysUser/findUserList',
                method: 'get',
                data:{password:value},
                success: function(data){
                    if(data.length==0){
                        tf = true;
                    }
                }
            });
            if(tf){
                return "密码错误，请重新输入！";
            }
        },
        newPwd : function(value, item){
            if(value.length < 6){
                return "密码长度不能小于6位";
            }
        },
        confirmPwd : function(value, item){
            if(!new RegExp($("#oldPwd").val()).test(value)){
                return "两次输入密码不一致，请重新输入！";
            }
        }
    });

    //提交
    layuiFunciton.formSubmit({
        filterName:'changePwd',
        url:  layuiFunciton.URL + '/sysUser/updateSysUser',
        formId:'changePwdForm',
        success:function (data) {
            if(data==1){
                layuiFunciton.success("修改成功！",function () {
                    layuiFunciton.ajaxRequest({
                        url:  layuiFunciton.URL + '/sign/logout',
                        method: 'get',
                        success: function(data){
                            window.parent.location.href="/page/login/login.html";
                        }
                    });
                })
            }
        }
    })
});